package com.atguigu.stgy.admin.controller;

import com.atguigu.stgy.admin.service.FileService;
import com.atguigu.stgy.model.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Tag(name = "文件管理模块")
@RestController
@RequestMapping("/admin/file")
public class FileController {

    @Resource
    FileService fileService;

    ///upload
    @Operation(summary = "文件上传")
    @PostMapping("upload")
    public R<String> upload(@RequestParam("file") MultipartFile multiPartFile){
        //上传到minio 返回文件再minio中的地址
        String path = fileService.upload(multiPartFile);
        return R.ok(path);
    }

}